﻿@model AdminViewModel
@{
    ViewBag.Title = "Kelper - Administrative page";
}

<h5>Note: This administration page is highly temporary and should be redesigned before going into production.</h5>

<h2>Categories</h2>
<table>
    <tr><th>ID</th><th>Name</th></tr>
    @foreach (var c in Model.Categories)
    {
        <tr>
            <td>@c.ID</td>
            <td>
                @using (Html.BeginForm("rename-category", "admin", null, FormMethod.Post,
                                       new { @class = "action-button" }))
                {
                    <div>
                        @Html.Hidden("oldName", c.Name)
                        @Html.TextBox("newName", c.Name)
                        <input type="submit" value="Rename" data-confirm="Are you sure you want to rename @c.Name?" />
                    </div>
                }       
            </td>
            <td>
                @using (Html.BeginForm("remove-category", "admin", new { id = c.Name }, FormMethod.Post,
                                       new { @class = "action-button" })) {
                    <div><input type="submit" value="Remove" data-confirm="Are you sure you want to remove @c.Name?" /></div>
                }
            </td>
        </tr>
    }
</table>
<h4>Add new category</h4>
@using (Html.BeginForm("add-category", "admin"))
{
    <div>
        Name: @Html.TextBox("name")
        <input type="submit" value="Add!" />
    </div>
}
<h2>Users</h2>
<table>
    <tr><th>Name</th><th>Email</th></tr>
    @foreach (var u in Model.Users)
    {
        <tr>
            <td>@u.Username</td> 
            <td>@u.Email</td>
            <td>
                @using (Html.BeginForm("remove-user", "admin", new { id = u.Username }, FormMethod.Post,
                        new { @class = "action-button" }))
                {
                    <div><input type="submit" value="Remove" data-confirm="Are you sure you want to remove @u.Username?" /></div>
                }
            </td>
        </tr>
    }
</table>